<script>
import api from "@/api";

export default {
  name: "index",
  data() {
    return {
      total: 0,
      tableData: [],
      currentTab: 1,
      queryParam: {
        searchType: "",
        keyword: "",
        pageSize: 5,
        pageNum: 1
      }
    }
  },
  mounted() {
    console.log('>>>>>>>>>>>>this.$route.query',this.$route.query)
    this.queryParam={...this.queryParam,...this.$route.query}
    this.fetchData()
  },
  methods: {
    async fetchData() {
      let data = await api.xing_zheng_gong_kai({...this.queryParam})
      this.tableData = data.records
      this.total = data.total
    },
    handleCurrentChange(size) {
      this.queryParam.pageNum = size
      this.fetchData()
    },
    handleSizeChange(size) {
      this.queryParam.pageSize = size
      this.fetchData()
    }
  }
}
</script>

<template>
  <el-row>
    <el-col :span="24">
      <div class="flex items-center">
        <el-select v-model="queryParam.searchType" clearable>
          <el-option value="" label="全部">全部</el-option>
          <el-option value="biao_ti" label="标题"></el-option>
          <el-option value="zheng_wen" label="正文"></el-option>
          <el-option value="wen_hao" label="文号"></el-option>
          <el-option value="ji_gou" label="机构"></el-option>
          <el-option value="mo_kuai" label="模块"></el-option>
        </el-select>
        <el-input v-model="queryParam.keyword" placeholder="请输入关键字"></el-input>
        <el-button type="default" icon="el-icon-search"></el-button>
      </div>
    </el-col>
    <el-col :span="24" class="bg-white p-3" v-for="(item,index) in tableData" :key="index">
      <div>
        <router-link :to="`/zhu_dong_gong_kai/detail?id=${item.id}`">
          <div class="p-3">
            <div class="text-lg text-black">{{ item.title }}</div>
            <div class="flex justify-between text-gray-500">
              <span class="py-1">发文机构：<span>{{ item.department }}</span></span>
              <span class="py-1">文号：<span>{{ item.articleNo }}</span></span>
              <span class="py-1">发文日期：<span>{{ item.createdAt }}</span></span>
            </div>
          </div>
        </router-link>
      </div>
    </el-col>
    <el-col :span="24" class="mt-2 flex justify-center">
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="queryParam.pageNum"
          :page-sizes="[5,10,20]"
          :page-size="queryParam.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
      </el-pagination>
    </el-col>
  </el-row>
</template>

<style scoped>

</style>
